<?php
// +-------------------------------------------------------------------------------
// | DingZone [ A Rapid Development Framework For Dingtalk ]
// +-------------------------------------------------------------------------------
// | ExamController.php v1.0
// |
// | Copyright (c) 2014-2018 http://www.heimalanshi.com All rights reserved.
// | Author : rahul
// | Date : 2018/11/5
// +-------------------------------------------------------------------------------
namespace app\core\controller\site;

use app\core\common\bean\BeanController;
use app\core\common\bean\BFC;

class CronLogController extends SiteBaseController {
    use BeanController;

    const RESULT_NORMAL = 1;
    const RESULT_ABNORMAL = 0;

    public static $RESULTS = [
        self::RESULT_NORMAL => '正常结束',
        self::RESULT_ABNORMAL => '异常终止'
    ];

    protected function _getBeanName() {
        return "cron_task_log";
    }

    protected function _enableEid() {
        return false;
    }

    protected function _getBeanFieldsConfig() {
        $configs = $this->_getDefaultBeanFieldsConfig();

        $configs['cron_task_id'][BFC::HIDE] = true;
        $configs['gmt_started'][BFC::TYPE] = BFC::TYPE_TIMESTAMP;
        $configs['gmt_ended'][BFC::TYPE] = BFC::TYPE_TIMESTAMP;

        $configs['hostname'][BFC::WIDTH] = 150;
        $configs['ops_server'][BFC::WIDTH] = 150;
        $configs['gmt_started'][BFC::WIDTH] = 180;
        $configs['gmt_ended'][BFC::WIDTH] = 180;
        $configs['escape'][BFC::WIDTH] = 150;
        $configs['result'][BFC::WIDTH] = 150;
        $configs['log'][BFC::MIN_WIDTH] = 150;

        return $configs;
    }

    protected function _getTableHeight() {
        return 'full-20';
    }

    protected function _rowPreProcess(&$row) {
        $row['result'] = fetch(self::$RESULTS, $row['result'], '');
    }

    protected function _getQueryConditions() {
        $conditions['cron_task_id'] = input('get.id');
        return $conditions;
    }
}